package com.hepinghospital.user.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hepinghospital.user.R;
import com.hepinghospital.user.util.UtilString;
import com.rest.response.PrescriptionResponse;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Description
 * Created by lbj on 2023/1/11 9:04
 */

public class AliPayFeeAdapter extends RecyclerView.Adapter<AliPayFeeAdapter.ViewHolder> {


    private Context context;
    private List<PrescriptionResponse.Prescription> list;

    public AliPayFeeAdapter(Context context, List<PrescriptionResponse.Prescription> list) {
        this.context = context;
        this.list = list;
    }


    @NotNull
    @Override
    public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        ViewHolder myHolder;
        myHolder = new ViewHolder( LayoutInflater.from( context ).inflate( R.layout.item_alipay_medicine, parent, false ) );
        return myHolder;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        holder.tvMedicineName.setText( list.get( position ).name );
        holder.tvMedicineNum.setText( "x" + list.get( position ).drugNumber );
//        holder.tv_medicine_price.setText( list.get( position ).expense + "*" + list.get( position ).drugNumber + "=" + list.get( position ).totalExpense + "元" );
        holder.tvMedicinePrice.setText( list.get( position ).totalExpense );
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_medicine_name)
        TextView tvMedicineName;
        @BindView(R.id.tv_medicine_num)
        TextView tvMedicineNum;
        @BindView(R.id.tv_medicine_price)
        TextView tvMedicinePrice;

        public ViewHolder(View itemView) {
            super( itemView );
            ButterKnife.bind( this, itemView );
        }
    }
}
